<?php

namespace App\Admin\Controllers;

use App\Models\ForumTaxonomy;
use Encore\Admin\Http\Controllers\AdminController;
use Encore\Admin\Form;
use Encore\Admin\Layout\Content;
use Encore\Admin\Show;
use Encore\Admin\Table;

class ForumTaxonomyController extends AdminController
{
    protected $title = "版块分类";


    /**
     * Make a grid builder.
     *
     * @return Table
     */
    protected function table()
    {
        $table = new Table(new ForumTaxonomy);

        $table->id('Id');
        $table->name('Name');
        $table->icon('Icon');
        $table->display_order('Display order');
        $table->created_at('Created at');
        $table->updated_at('Updated at');

        return $table;
    }

    /**
     * Make a show builder.
     *
     * @param mixed   $id
     * @return Show
     */
    protected function detail($id)
    {
        $show = new Show(ForumTaxonomy::findOrFail($id));

        $show->id('Id');
        $show->name('Name');
        $show->icon('Icon');
        $show->display_order('Display order');
        $show->created_at('Created at');
        $show->updated_at('Updated at');

        return $show;
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        $form = new Form(new ForumTaxonomy);

        $form->text('name', 'Name');
        $form->text('icon', 'Icon');
        $form->number('display_order', 'Display order')->default(0);

        return $form;
    }
}
